package com.dmwork.service.interaction.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dmwork.service.interaction.entity.Feed;
import com.dmwork.service.interaction.mapper.FeedMapper;
import com.dmwork.service.interaction.service.FeedService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户动态表 服务实现类
 * </p>
 *
 * @author 李天
 * @since 2021-03-25
 */
@Service
public class FeedServiceImpl extends ServiceImpl<FeedMapper, Feed> implements FeedService {

    @Override
    public Page<Feed> getOwnFeedByCustomerIdPage(String customerId, Integer page, Integer limit) {
        Page<Feed> feedPage = new Page<>(page, limit);
        QueryWrapper<Feed> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("customer_id", customerId).orderByDesc("gmt_create");
        feedPage = baseMapper.selectPage(feedPage, queryWrapper);
        return feedPage;
    }

    @Override
    public Page<Feed> getFeedByCustomerIdListPage(List<String> customerIdList, Integer page, Integer limit) {
        Page<Feed> feedPage = new Page<>(page, limit);
        QueryWrapper<Feed> queryWrapper = new QueryWrapper<Feed>()
                .in("customer_id", customerIdList)
                .orderByDesc("gmt_create");
        feedPage = baseMapper.selectPage(feedPage, queryWrapper);
        return feedPage;
    }

    @Override
    public Page<Feed> getCustomerFeedList(String customerId, Integer page, Integer limit) {
        QueryWrapper<Feed> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("customer_id", customerId).orderByDesc("gmt_create");
        Page<Feed> feedPage = new Page<>(page, limit);
        return baseMapper.selectPage(feedPage, queryWrapper);
    }
}
